<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0, minimum-scale=1.0, user-scalable=0, initial-scale=1.0, width=device-width" />
    <meta name="format-detection" content="telephone=no, email=no, date=no, address=no">
    <title>代办物料列表</title>
    <link rel="stylesheet" type="text/css" href="../css/mui.min.css" />
    <link rel="stylesheet" type="text/css" href="../css/common.css"/>
</head>

<body>
	<div class="mui-content">
		<ul class="mui-table-view01">
			 <li class="search-cell">
			 	<div class="mui-input-row mui-search">
					<input type="search" id="searchText" class="mui-input-clear" placeholder="请输入关键字搜索" ><span class="mui-icon mui-icon-clear mui-hidden"></span><span class="mui-placeholder"><span></span></span>
				</div>
				<div class="mui-btn mui-btn-primary" onclick="Search()">
					搜索
				</div>
			 </li>
		</ul>
		<div class="mui-content">
      <ul class="mui-table-view deal_list" id="todoCnt">
          <script type="text/template" id="tmpList">
              {{each datas as item i}}
              <li class="mui-table-view-cell" tapmode onclick="openMaterialDetailWin('{{item.matusetransid}}','{{item.inventoryid}}','{{item.status}}','{{item.invbalancesid}}')">
                  <div class="mui-table">
                      <div class="mui-table-cell mui-col-xs-9">
                      	  {{if item.isTimeOut == '1'}}
                          <h4 class="mui-ellipsis"><img src="../image/warning.png" style="width:0.8rem;display:inline-block;margin-right:0.2rem;"/>{{item.itemnum}}<span style="font-size:0.6rem;margin-left:0.6rem;">{{item.itemDesc}}</span></h4>
                          {{else}}
                          <h4 class="mui-ellipsis">{{item.itemnum}}<span style="font-size:0.6rem;margin-left:0.6rem;">{{item.itemDesc}}</span></h4>
                          {{/if}}
                          <p class="mui-h6 mui-ellipsis">{{item.description}}</p>
                      </div>
                      <div class="mui-table-cell mui-col-xs-3 mui-text-right">
                        {{if item.status==1}}
                          <span class="mui-h5">出库审批</span>
                          {{else if item.status == 2}}
                          <span class="mui-h5">修改物料</span>
                          {{/if}}
                      </div>
                  </div>
              </li>
              {{/each}}
          </script>
          <div class="mui-hidden" id="stockdbTip">
            <p class="no_list">暂无待办</p>
        </div>
      </ul>
		</div>
	</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script src="../script/mui.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/common.js" type="text/javascript" charset="utf-8"></script>
<script src="../script/template.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	var FNScanner;
	var cRegion = '', orderType = '', userID = '',statusId,searchText;
	apiready = function () {
		FNScanner = api.require('FNScanner');
		onLoadData(curPage,false);
		cRegion = api.pageParam.location;
		orderType = api.pageParam.orderType;
		scrollToBottomHandler(function() {
			if (!loadEnd) { // 没有结束时继续加载
				curPage++;
				onLoadData(curPage,true);
			} else { // 告诉到底了
				EndToast('到底了');
			}
		})
		Refresh(function() {
			loadEnd = false;
			curPage = 1;
			onLoadData(curPage,false);
		});
		api.parseTapmode();
	    api.addEventListener({
	        name: 'renovate'
	    }, function(ret, err) {
	      if(ret.value.isRenovate == 'true'){
	        onLoadData(curPage,false);
	      }
	    })
	    api.addEventListener({
		    name:'navitembtn'
		},function(ret, err){
		    if(ret.type == 'right'){
		    	Scanner(4);
		    }
	  })
	}
  // 物料出库
  function openMaterialDetailWin(matusetransid,inventoryid,status,invbalancesid){
    if(status == '1') {
      openTastWin('stock_out_detail','出库审批',{
        matusetransid: matusetransid,
            inventoryid:inventoryid,
            invbalancesid: invbalancesid
        })
    } else{
      openSaveWin('stock_out_edit','编辑物料出库',{
          matusetransid:matusetransid,
          invbalancesid: invbalancesid
      })
    }

  }
  function openOrderEditWin(itemid,inventoryid){
		openWin('stock_edit','修改物料',{
	        background: '#6098de',
	        color: '#fff',
	        rightButtons:[{
	        	iconPath:"widget://image/save-icon.png"
	        }]
	    },{
	    	itemid:itemid,
	    	inventoryid:inventoryid
	    })
	}
	function onLoadData (page,load) {
		searchText = $api.val($api.byId('searchText'));
    ajaxrd("queryMaterialsTodoList", {
        itemnum:searchText || '',
        pageNo: page,
        pageSize: 10
    }, function(ret, err) {
        api.refreshHeaderLoadDone();
        AddData('tmpList', 'todoCnt', ret.list, load);
        if (ret.list.length < 10) {
            loadEnd = true
        }
    })
	}

  function Search(){
    loadEnd = false;
    curPage = 1;
    onLoadData(curPage,false);
  }
</script>

</html>
